// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()


// 云函数入口函数
exports.main = async (event, context) => {
  const {
    OPENID
  } = cloud.getWXContext()
  try {
    const result = await cloud.openapi.subscribeMessage.send({
      touser: OPENID,
      page: `/pages/blog-comment/blog-comment?blogId=${event.blogId}`,
      lang: 'zh_CN',
      data: {
        name2: {
          value: event.nickName
        },
        thing3: {
          value: event.content
        }
      },
      templateId: 'jY8rOO86r5CI5jAYnpgKHjivOTEhpdQufii7YeEIhvI'
    })
    return result
  } catch (err) {
    return err
  }
}